package com.pakazaka.testItemsSystem;

import com.pakazaka.json.ParseJSON;
import com.pakazaka.player.Player;
import java.util.HashMap;

/**
 * @author Riseremi
 */
public class ItemPrototype {
    //item ids

    public static ItemPrototype instance;
    //hashmaps
    private HashMap<String, String> imageIds; // id : name
    private HashMap<String, String> names; // id : name
    private HashMap<String, String> descriptions; // id : description
    private HashMap<String, String> maxDurabilities; //etc
    private HashMap<String, String> weights;
    private HashMap<String, String> volumes;
    private HashMap<String, String> noises;
    private HashMap<String, String> materials;
    private HashMap<String, String> properties;
    private HashMap<String, Item.Type> types;
    private HashMap<Item.Type, String> actions;
    private HashMap<String, String> powers;
    private HashMap<String, String> afterUse;
    private HashMap<String, String> cutProtection = new HashMap<>();
    private HashMap<String, String> bashProtection = new HashMap<>();
    private HashMap<String, String> pierceProtection = new HashMap<>();
    private HashMap<String, String> comfort = new HashMap<>();
    private HashMap<String, Item.Slot> slot = new HashMap<>();
    private HashMap<String, Player.EffectType[]> effect;

    public ItemPrototype(HashMap<String, String> names,
            HashMap<String, String> descriptions, HashMap<String, String> maxDurabilities,
            HashMap<String, String> weights, HashMap<String, String> volumes,
            HashMap<String, String> noises, HashMap<String, String> materials,
            HashMap<String, Item.Type> types, HashMap<String, String> properties,
            HashMap<String, String> imageIds, HashMap<String, String> powers,
            HashMap<String, String> afterUse, HashMap<String, Player.EffectType[]> effect,
            HashMap<String, String> cutProtection,
            HashMap<String, String> bashProtection,
            HashMap<String, String> pierceProtection,
            HashMap<String, String> comfort, HashMap<String, Item.Slot> slot) {

        this.names = names;
        this.descriptions = descriptions;
        this.maxDurabilities = maxDurabilities;
        this.weights = weights;
        this.volumes = volumes;
        this.powers = powers;
        this.noises = noises;
        this.materials = materials;
        this.properties = properties;
        this.types = types;
        this.imageIds = imageIds;
        this.afterUse = afterUse;
        this.effect = effect;
        this.cutProtection = cutProtection;
        this.bashProtection = bashProtection;
        this.pierceProtection = pierceProtection;
        this.comfort = comfort;
        this.slot = slot;
        //System.out.println("source imageids: " + imageIds.toString());
    }

    public static void setPrototype(ItemPrototype prototype) {
        ItemPrototype.instance = prototype;
    }

    public static ItemPrototype getInstance() {
        return instance;
    }

    public String getMaxDurabilityById(String id) {
        return maxDurabilities.get(id);
    }

    public String getActionById(String id) {
        return actions.get(id);
    }

    public String[] getActionsById(String id) {
        return getActionById(id).split("::");
    }

    public String getWeightById(String id) {
        return weights.get(id);
    }

    public int getVolumeById(String id) {
        return Integer.parseInt(volumes.get(id));
    }

    public String getNoiseById(String id) {
        return noises.get(id);
    }

    public int getImageIdById(String id) {
        return Integer.parseInt(imageIds.get(id));
    }

    public String[] getMaterialsById(String id) {
        return getMaterialById(id).split(ParseJSON.PROPEERTY_SEPARATOR);
    }

    private String getMaterialById(String id) {
        return materials.get(id);
    }

    public Player.EffectType[] getEffectsById(String id) {
        return effect.get(id);
    }

//    private Item.Effect getEffectById(String id) {
//        return effect.get(id);
//    }
    private String getPropertyById(String id) {
        return properties.get(id);
    }

    public String[] getPropertiesById(String id) {
        return getPropertyById(id).split("::");
    }

    public Item.Type getTypeById(String id) {
        return types.get(id);
    }

    public String getDescriptionById(String id) {
        return descriptions.get(id);
    }

    public String getNameById(String id) {
        return names.get(id);
    }

    public String getAfterUseById(String id) {
        return afterUse.get(id);
    }

    public int getPowerById(String id) {
        return Integer.parseInt(powers.get(id));
    }

    public Item.Slot getWearSlot(String id) {
        return slot.get(id);
    }

    public int getCutProtectionById(String id) {
        return Integer.parseInt(cutProtection.get(id));
    }

    public int getBashProtectionById(String id) {
        return Integer.parseInt(bashProtection.get(id));
    }

    public int getPierceProtectionById(String id) {
        return Integer.parseInt(pierceProtection.get(id));
    }
}
